package mapper;

import entity.User;
import utils.DBConn;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class UserMapper {

    //添加用户信息
    public int insertUser(User user){
        int i=0;
        Connection connection = DBConn.getConnection();
        String sql="insert into user(username,password,email) values(?,?,?)";
        try {
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1, user.getName());
            preparedStatement.setString(2,user.getPassword());
             i = preparedStatement.executeUpdate();

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return i;

    }



}
